import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

void main() {
  runApp(MaterialApp(home: TextHomePage()));
}

class TextHomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return TextHomePageState();
  }
}

class TextHomePageState extends State<TextHomePage> {
  String url = "https://api.wmdb.tv/api/v1/top?type=Imdb&skip=0&limit=20&lang=Cn";
  // String url = "http://192.168.43.102:8080/saves";
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    var dio = Dio();
    dio.get(url).then((value) {
      print(value);
      List<Map<String,dynamic>> planListObj = json.decode(value.toString());
    });

  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("listview"),
          ),
          body: getcar()
      ),
    );
  }
}

Card getcar() {
  return Card(
    //  设置圆角
    shape: RoundedRectangleBorder(
      //形状修改圆角
      borderRadius: BorderRadius.all(Radius.circular(9)),
    ),
    color: Colors.white,
    elevation: 4.0,
    shadowColor: Colors.grey,
    child:getitem(),
  );
}
Widget getitem(){
  return Column(
    mainAxisSize: MainAxisSize.min,
    children: [
      SizedBox(height: 4,),
      Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SizedBox(width: 3,),
          Image(
            image: NetworkImage(
                "https://wmdb.querydata.org/movie/poster/1603701754760-c50d8a.jpg"
            ),
            width: 100,
            height: 150,
            fit: BoxFit.cover,
          ),
          SizedBox(width: 10,),
          Expanded(
            flex: 1,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("喜剧之王",style: TextStyle(fontSize: 20,fontWeight: FontWeight.bold,),),
                SizedBox(height: 5,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    Text("2022-04-14",style: TextStyle(color: Colors.black54)),
                    SizedBox(width: 5,),
                    Text("犯罪/剧情",style: TextStyle(color: Colors.black54)),
                    SizedBox(width: 5,),
                    Text("美国",style: TextStyle(color: Colors.black54))
                  ],),
                SizedBox(height: 5,),
                Text("40年代末，小有成就的青年银行家安迪（蒂姆·罗宾斯 Tim Robbins 饰）因涉嫌杀害妻子及她的情人而锒铛入狱。在这座名为鲨堡的监狱内，希望似乎虚无缥缈，终身监禁的惩罚无疑注定了安迪接下来..",
                  maxLines: 3,
                  softWrap: true,
                  textAlign: TextAlign.start,
                  style: TextStyle(color: Colors.black54),
                )
              ],
            ),
          )
        ],
      ),
      SizedBox(height: 3,)
    ],
  );
}
